<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>#div1{width:200px;height:150px;background-color: gold;position:absolute;right:0;bottom:0;}</style>
    <script>
 window.onscroll=window.onresize=function(){//onscroll当页面滚动时会发生//onresize当窗口发生变化时发生
     var oDiv=document.getElementById('div1');
     var scrollTop=document.documentElement.scrollTop;
//     oDiv的top位置是由 滚动距离+（可视区高度-物体本身的高度）
     oDiv.style.top=document.documentElement.clientHeight-oDiv.offsetHeight+scrollTop+'px';
 };
    </script>
</head>
<body style="height: 3000px;">
<div id="div1"></div>
</body>
</html>